package com.garen.fire.dao.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Repository;

import com.garen.common.BaseDaoXf;
import com.garen.fire.dao.IFireWellDao;
import com.garen.utils.MapBuilder;

@Repository
public class FireWellDaoImpl extends BaseDaoXf<Map<String, Object>> 
		implements IFireWellDao{


	@PostConstruct
	private void init(){
		initOrm(Map.class);
	}
	/*
	 * 获取案情派遣车辆信息
	 * */
	@Override
	public List<Map<String, Object>> getCaseCars(String ajbh){
		String sql = " SELECT  CMDORGID,ACTINF from SI_COMMAND WHERE EVENTID = :ajbh ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("ajbh", ajbh)
				 .build();
		return queryForList(sql, paramMap);
	}
	
	public Map<String, Object>  gettable(String tableName){
		String sql = " SELECT * FROM " + tableName + " WHERE rownum = 1  ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("tableName", tableName)
				 .build();
		return queryForMap(sql, paramMap);
	}
	
	/*
	 * 指定表数据
	 * */
	public List<Map<String, Object>>  gettables(String tableName){
		String sql = " SELECT * FROM " + tableName + " WHERE rownum < 10  ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("tableName", tableName)
				 .build();
		return queryForList(sql, paramMap);
	}
	
	public List<Map<String, Object>>  getAlltables(){
		String sql = " select table_name,num_rows from user_tables ORDER BY num_rows DESC  ";
		Map<String,Object> paramMap = new MapBuilder()
				 .build();
		return queryForList(sql, paramMap);
	}
	
	//获取案情录音
	@Override
	public Map<String, Object>  getCaseSound(String ajbh){
		String sql = "SELECT EVENTID, FILEPATH,FILENAME FROM CTI_RECORDLIST  "
				+ "WHERE EVENTID = :ajbh  ORDER BY EVENTID DESC ";
		Map<String,Object> paramMap = new MapBuilder()
				 .put("ajbh", ajbh)
				 .build();
		return queryForMap(sql, paramMap);
	}
	
}
